package com.wing.bill.service;

import com.wing.bill.dao.WeighCabinetReportDao;
import com.wing.cabinet.utils.FindDateStatusUtil;
import com.wing.common.utils.JsonResult;
import com.wing.common.utils.LocalDateTimeUtils;
import com.wing.wcabinet.dao.WcabCellInventoryInoutDao;
import com.wing.wcabinet.dao.WcabCheckedResultDao;
import com.wing.wcabinet.model.entity.WcabCellInventoryInout;
import com.wing.wcabinet.model.entity.WcabCheckedResult;
import com.wing.web.db.config.util.DynamicDataSource;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.*;

@Service
public class WeighCabinetReportServiceImpl implements WeighCabinetReportService{

    @Autowired
    private WeighCabinetReportDao weighCabinetReportDao;

    @Autowired
    private WcabCellInventoryInoutDao wcabCellInventoryInoutDao;

    @Autowired
    private WcabCheckedResultDao wcabCheckedResultDao;

    @Override
    public JsonResult exhibitList(String type, String startTime, String endTime, String click, String code) {
        List list = new ArrayList();
        HashMap map1 = new HashMap(){{put("title","上货重量(g)");put("sign","1");}};
        HashMap map2 = new HashMap(){{put("title","上货数量");put("sign","1");}};
        HashMap map3 = new HashMap(){{put("title","上货金额(元)");put("sign","1");}};
        HashMap map4 = new HashMap(){{put("title","补货重量(g)");put("sign","1");}};
        HashMap map5 = new HashMap(){{put("title","补货数量");put("sign","1");}};
        HashMap map6 = new HashMap(){{put("title","补货金额(元)");put("sign","1");}};
        if(StringUtils.isNotBlank(type)&&click.equals("0")){
            if(type.equals("1")){ // 日
                map1.putAll(weighCabinetReportDao.queryExhibitWeight(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,1,1));
                map2.putAll(weighCabinetReportDao.queryExhibitQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,1,1));
                map3.putAll(weighCabinetReportDao.queryExhibitMoney(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,1,1));
                map4.putAll(weighCabinetReportDao.querySubsidyWeight(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map5.putAll(weighCabinetReportDao.querySubsidyQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map6.putAll(weighCabinetReportDao.querySubsidyMoney(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(type.equals("2")){ // 周
                map1.putAll(weighCabinetReportDao.queryExhibitWeight(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,1,1));
                map2.putAll(weighCabinetReportDao.queryExhibitQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,1,1));
                map3.putAll(weighCabinetReportDao.queryExhibitMoney(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,1,1));
                map4.putAll(weighCabinetReportDao.querySubsidyWeight(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map5.putAll(weighCabinetReportDao.querySubsidyQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map6.putAll(weighCabinetReportDao.querySubsidyMoney(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(type.equals("3")){// 月
                map1.putAll(weighCabinetReportDao.queryExhibitWeight(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,1,1));
                map2.putAll(weighCabinetReportDao.queryExhibitQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,1,1));
                map3.putAll(weighCabinetReportDao.queryExhibitMoney(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,1,1));
                map4.putAll(weighCabinetReportDao.querySubsidyWeight(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map5.putAll(weighCabinetReportDao.querySubsidyQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map6.putAll(weighCabinetReportDao.querySubsidyMoney(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            list.add(map5);
            list.add(map6);
            return JsonResult.success("查询成功", list);
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("0")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            map1.putAll(weighCabinetReportDao.queryExhibitWeight(start,end,code,1,1));
            map2.putAll(weighCabinetReportDao.queryExhibitQuantity(start,end,code,1,1));
            map3.putAll(weighCabinetReportDao.queryExhibitMoney(start,end,code,1,1));
            map4.putAll(weighCabinetReportDao.querySubsidyWeight(start,end,code));
            map5.putAll(weighCabinetReportDao.querySubsidyQuantity(start,end,code));
            map6.putAll(weighCabinetReportDao.querySubsidyMoney(start,end,code));
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            list.add(map5);
            list.add(map6);
            return JsonResult.success("查询成功", list);
        }
        //------------------------------------------------- 头部点击事件按日周月查询start ------------------------------------
        //上货重量 上货数量  上货金额
        if(StringUtils.isNotBlank(type)&&(click.equals("1") || click.equals("2") || click.equals("3"))){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("inoutType", WcabCellInventoryInout.InoutType.in.getValue());
            params.put("operationType", WcabCellInventoryInout.OperationType.load.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }
        }
        //补货重量  补货数量  补货金额
        if(StringUtils.isNotBlank(type)&&(click.equals("4") || click.equals("5") || click.equals("6"))){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("operationType",WcabCellInventoryInout.OperationType.supplyIn.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }
        }
        //------------------------------------------------- 头部点击事件按日周月查询end ------------------------------------
        //------------------------------------------------- 头部点击事件按时间区间查询start ------------------------------------
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            if(click.equals("1") || click.equals("2") || click.equals("3")){//上货重量 上货数量  上货金额
                params.put("inoutType", WcabCellInventoryInout.InoutType.in.getValue());
                params.put("operationType", WcabCellInventoryInout.OperationType.load.getValue());
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(click.equals("4") || click.equals("5") || click.equals("6")){//补货重量  补货数量  补货金额
                params.put("operationType",WcabCellInventoryInout.OperationType.supplyIn.getValue());
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }
        }
        return JsonResult.fail("查询失败");
    }

    @Override
    public JsonResult stockList(String type, String startTime, String endTime, String click, String code) {
        List list = new ArrayList();
        HashMap map1 = new HashMap(){{put("title","领新重量(g)");put("sign","1");}};
        HashMap map2 = new HashMap(){{put("title","领新数量");put("sign","1");}};
        HashMap map3 = new HashMap(){{put("title","领新金额(元)");put("sign","1");}};
        HashMap map4 = new HashMap(){{put("title","在库总重量(g)");put("sign","3");}};
        HashMap map5 = new HashMap(){{put("title","在库物料数量");put("sign","3");}};
        HashMap map6 = new HashMap(){{put("title","在库总价值(元)");put("sign","3");}};
        if(StringUtils.isNotBlank(type)&&click.equals("0")){
            // 日
            if(type.equals("1")){
                map1.putAll(weighCabinetReportDao.queryExhibitWeight(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,2,3));
                map2.putAll(weighCabinetReportDao.queryExhibitQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,2,3));
                map3.putAll(weighCabinetReportDao.queryExhibitMoney(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,2,3));
                map4.putAll(weighCabinetReportDao.queryInStockWeight(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map5.putAll(weighCabinetReportDao.queryInStockQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map6.putAll(weighCabinetReportDao.queryInStockMoney(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(type.equals("2")){ // 周
                map1.putAll(weighCabinetReportDao.queryExhibitWeight(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,2,3));
                map2.putAll(weighCabinetReportDao.queryExhibitQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,2,3));
                map3.putAll(weighCabinetReportDao.queryExhibitMoney(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,2,3));
                map4.putAll(weighCabinetReportDao.queryInStockWeight(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map5.putAll(weighCabinetReportDao.queryInStockQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map6.putAll(weighCabinetReportDao.queryInStockMoney(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(type.equals("3")){ // 月
                map1.putAll(weighCabinetReportDao.queryExhibitWeight(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,2,3));
                map2.putAll(weighCabinetReportDao.queryExhibitQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,2,3));
                map3.putAll(weighCabinetReportDao.queryExhibitMoney(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,2,3));
                map4.putAll(weighCabinetReportDao.queryInStockWeight(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map5.putAll(weighCabinetReportDao.queryInStockQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map6.putAll(weighCabinetReportDao.queryInStockMoney(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            list.add(map5);
            list.add(map6);
            return JsonResult.success("查询成功", list);
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("0")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            map1.putAll(weighCabinetReportDao.queryExhibitWeight(start,end,code,2,3));
            map2.putAll(weighCabinetReportDao.queryExhibitQuantity(start,end,code,2,3));
            map3.putAll(weighCabinetReportDao.queryExhibitMoney(start,end,code,2,3));
            map4.putAll(weighCabinetReportDao.queryInStockWeight(start,end,code));
            map5.putAll(weighCabinetReportDao.queryInStockQuantity(start,end,code));
            map6.putAll(weighCabinetReportDao.queryInStockMoney(start,end,code));
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            list.add(map5);
            list.add(map6);
            return JsonResult.success("查询成功", list);
        }
        //------------------------------------------------- 头部点击事件按日周月查询start ------------------------------------
        //领新重量 领新数量  领新金额
        if(StringUtils.isNotBlank(type)&&(click.equals("1") || click.equals("2") || click.equals("3"))){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("inoutType", WcabCellInventoryInout.InoutType.out.getValue());
            params.put("operationType", WcabCellInventoryInout.OperationType.out.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }
        }
        //在库总重量  在库物料数量   在库总价值
        if(StringUtils.isNotBlank(type)&&(click.equals("4") || click.equals("5") || click.equals("6"))){
            if(type.equals("1")){
                return JsonResult.success("查询成功",weighCabinetReportDao.queryInStockWeightClick(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(type.equals("2")){
                return JsonResult.success("查询成功",weighCabinetReportDao.queryInStockWeightClick(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(type.equals("3")){
                return JsonResult.success("查询成功",weighCabinetReportDao.queryInStockWeightClick(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
        }
        //------------------------------------------------- 头部点击事件按日周月查询end ------------------------------------
        //------------------------------------------------- 头部点击事件按时间区间查询start ------------------------------------
        //领新重量 领新数量 领新金额
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("inoutType", WcabCellInventoryInout.InoutType.out.getValue());
            params.put("operationType", WcabCellInventoryInout.OperationType.out.getValue());
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            if(click.equals("1")||click.equals("2")||click.equals("3")){
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(click.equals("4")||click.equals("5")||click.equals("6")){ //在库总重量  在库物料数量  在库总价值
                return JsonResult.success("查询成功",weighCabinetReportDao.queryInStockWeightClick(start,end,code));
            }
        }
        return JsonResult.fail("查询失败");
    }

    @Override
    public JsonResult returnedList(String type, String startTime, String endTime, String click, String code) {
        List list = new ArrayList();
        HashMap map1 = new HashMap(){{put("title","退料重量(g)");put("sign","1");}};
        HashMap map2 = new HashMap(){{put("title","退料数量");put("sign","1");}};
        HashMap map3 = new HashMap(){{put("title","退料金额(元)");put("sign","1");}};
        HashMap map4 = new HashMap(){{put("title","退料次数");put("sign","1");}};
        if(StringUtils.isNotBlank(type)&&click.equals("0")){
            // 日
            if(type.equals("1")){
                map1.putAll(weighCabinetReportDao.queryReturnedWeight(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map2.putAll(weighCabinetReportDao.queryReturnedQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map3.putAll(weighCabinetReportDao.queryReturnedMoney(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
                map4.putAll(weighCabinetReportDao.queryReturnedFrequency(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(type.equals("2")){ // 周
                map1.putAll(weighCabinetReportDao.queryReturnedWeight(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map2.putAll(weighCabinetReportDao.queryReturnedQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map3.putAll(weighCabinetReportDao.queryReturnedMoney(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
                map4.putAll(weighCabinetReportDao.queryReturnedFrequency(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(type.equals("3")){ //  月
                map1.putAll(weighCabinetReportDao.queryReturnedWeight(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map2.putAll(weighCabinetReportDao.queryReturnedQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map3.putAll(weighCabinetReportDao.queryReturnedMoney(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
                map4.putAll(weighCabinetReportDao.queryReturnedFrequency(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            return JsonResult.success("查询成功", list);
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("0")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            map1.putAll(weighCabinetReportDao.queryReturnedWeight(start,end,code));
            map2.putAll(weighCabinetReportDao.queryReturnedQuantity(start,end,code));
            map3.putAll(weighCabinetReportDao.queryReturnedMoney(start,end,code));
            map4.putAll(weighCabinetReportDao.queryReturnedFrequency(start,end,code));
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            return JsonResult.success("查询成功", list);
        }
        //------------------------------------------------- 头部点击事件按日周月查询start ------------------------------------
        //退料重量  退料数量  退料金额 退料次数
        if(StringUtils.isNotBlank(type)&&(click.equals("1") || click.equals("2") || click.equals("3") ||click.equals("4"))){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("inoutType", WcabCellInventoryInout.InoutType.in.getValue());
            params.put("operationType", WcabCellInventoryInout.OperationType.returnIn.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }
        }
        //------------------------------------------------- 头部点击事件按日周月查询end ------------------------------------
        //------------------------------------------------- 头部点击事件按时间区间查询start ------------------------------------
        //退料重量  退料数量  退料金额  退料次数
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            Map<String, Object> params = new HashMap<>();
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            params.put("enterpriseCode",code);
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            params.put("inoutType", WcabCellInventoryInout.InoutType.in.getValue());
            params.put("operationType", WcabCellInventoryInout.OperationType.returnIn.getValue());
            if(click.equals("1")||click.equals("2")||click.equals("3")||click.equals("4")){
                return JsonResult.success("查询成功",wcabCellInventoryInoutDao.exhibitRecordList(null,params));
            }
        }

        return JsonResult.fail("查询失败");
    }

    @Override
    public JsonResult repairList(String type, String startTime, String endTime, String click, String code) {
        List list = new ArrayList();
        HashMap map1 = new HashMap(){{put("title","待盘验报修物料数量");put("sign","1");}};
        HashMap map2 = new HashMap(){{put("title","已盘验报修物料数量");put("sign","2");}};
        HashMap map3 = new HashMap(){{put("title","已盘验报修物料重量");put("sign","1");}};
        HashMap map4 = new HashMap(){{put("title","报修订单数量");put("sign","1");}};
        //待盘验报修物料数量不需要根据时间去查询
        map1.putAll(weighCabinetReportDao.queryMaterialsToTestedQuantity(code,2));
        if(StringUtils.isNotBlank(type)&&click.equals("0")){
            if(type.equals("1")){ //日
                map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,2));
                map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,2));
                map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,2));
            }else if(type.equals("2")){// 周
                map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,2));
                map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,2));
                map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,2));
            }else if(type.equals("3")){//月
                map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,2));
                map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,2));
                map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,2));
            }
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            return JsonResult.success("查询成功", list);
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("0")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(start,end,code,2));
            map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(start,end,code,2));
            map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(start,end,code,2));
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            return JsonResult.success("查询成功", list);
        }
        //------------------------------------------------- 头部点击事件按日周月查询start ------------------------------------
        //待盘验报修物料数量
        if(StringUtils.isNotBlank(type)&&click.equals("1")){  //待盘验不需要按照时间去查询
            return JsonResult.success("查询成功",weighCabinetReportDao.queryMaterialsToTestedQuantityClick(code,2));
        }
        //已盘验报修物料数量
        if(StringUtils.isNotBlank(type)&&click.equals("2")){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.repair.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dayUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dayUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }
        }
        //已盘验报修物料重量
        if(StringUtils.isNotBlank(type)&&click.equals("3")){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.repair.getValue());
            //params.put("isCorrect",0);
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dayUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dayUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }
        }
        //报修订单物料数量
        if(StringUtils.isNotBlank(type)&&click.equals("4")){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.repair.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dayUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dayUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }
        }
        //------------------------------------------------- 头部点击事件按日周月查询end ------------------------------------
        //------------------------------------------------- 头部点击事件按时间区间查询start ------------------------------------
        //待盘验报修物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("1")){
            return JsonResult.success("查询成功",weighCabinetReportDao.queryMaterialsToTestedQuantityClick(code,2));
        }
        //已盘验报修物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("2")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.repair.getValue());
            return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
        }
        //盘验报修异常物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("3")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
           // params.put("isCorrect",0);
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.repair.getValue());
            return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
        }
        //报修订单物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("4")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
            params.put("businessType", WcabCheckedResult.BusinessType.repair.getValue());
            params.put("enterpriseCode",code);
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
        }
        return JsonResult.fail("查询失败");
    }

    @Override
    public JsonResult recycleList(String type, String startTime, String endTime, String click, String code) {
        List list = new ArrayList();
        HashMap map1 = new HashMap(){{put("title","待盘验报废物料数量");put("sign","1");}};
        HashMap map2 = new HashMap(){{put("title","已盘验报废物料数量");put("sign","2");}};
        HashMap map3 = new HashMap(){{put("title","已盘验报废物料重量");put("sign","1");}};
        HashMap map4 = new HashMap(){{put("title","报废订单数量");put("sign","1");}};
        //待盘验报修物料数量不需要根据时间去查询
        map1.putAll(weighCabinetReportDao.queryMaterialsToTestedQuantity(code,3));
        if(StringUtils.isNotBlank(type)&&click.equals("0")){
            if(type.equals("1")){ //日
                map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,3));
                map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,3));
                map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,3));
            }else if(type.equals("2")){// 周
                map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,3));
                map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,3));
                map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,3));
            }else if(type.equals("3")){//月
                map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,3));
                map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,3));
                map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,3));
            }
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            return JsonResult.success("查询成功", list);
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("0")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            map2.putAll(weighCabinetReportDao.queryOrderedInspectionQuantity(start,end,code,3));
            map3.putAll(weighCabinetReportDao.queryOrderedInspectionExceptionQuantity(start,end,code,3));
            map4.putAll(weighCabinetReportDao.queryRepairOrderQuantity(start,end,code,3));
            list.add(map1);
            list.add(map2);
            list.add(map3);
            list.add(map4);
            return JsonResult.success("查询成功", list);
        }
        //------------------------------------------------- 头部点击事件按日周月查询start ------------------------------------
        //待盘验报修物料数量
        if(StringUtils.isNotBlank(type)&&click.equals("1")){  //待盘验不需要按照时间去查询
            return JsonResult.success("查询成功",weighCabinetReportDao.queryMaterialsToTestedQuantityClick(code,3));
        }
        //已盘验报修物料数量
        if(StringUtils.isNotBlank(type)&&click.equals("2")){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.recycle.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dayUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dayUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }
        }
        //已盘验报废物料重量
        if(StringUtils.isNotBlank(type)&&click.equals("3")){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.recycle.getValue());
            //params.put("isCorrect",0);
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dayUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dayUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }
        }
        //报修订单物料数量
        if(StringUtils.isNotBlank(type)&&click.equals("4")){
            Map<String, Object> params = new HashMap<>();
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.recycle.getValue());
            if(type.equals("1")){
                params.put("startCreateTime",FindDateStatusUtil.dayUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dayUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("2")){
                params.put("startCreateTime",FindDateStatusUtil.weekUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.weekUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }else if(type.equals("3")){
                params.put("startCreateTime",FindDateStatusUtil.dateUtil().get(0));
                params.put("endCreateTime",FindDateStatusUtil.dateUtil().get(1));
                return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
            }
        }
        //------------------------------------------------- 头部点击事件按日周月查询end ------------------------------------
        //------------------------------------------------- 头部点击事件按时间区间查询start ------------------------------------
        //待盘验报修物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("1")){
            return JsonResult.success("查询成功",weighCabinetReportDao.queryMaterialsToTestedQuantityClick(code,3));
        }
        //已盘验报修物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("2")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.recycle.getValue());
            return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
        }
        //已盘验报废物料重量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("3")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
           // params.put("isCorrect",0);
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            params.put("enterpriseCode",code);
            params.put("businessType", WcabCheckedResult.BusinessType.recycle.getValue());
            return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
        }
        //报修订单物料数量
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)&&click.equals("4")){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            Map<String, Object> params = new HashMap<>();
            params.put("businessType", WcabCheckedResult.BusinessType.recycle.getValue());
            params.put("enterpriseCode",code);
            params.put("startCreateTime",start);
            params.put("endCreateTime",end);
            return JsonResult.success("查询成功",wcabCheckedResultDao.findRepairRecordListList(null,params));
        }
        return JsonResult.fail("查询失败");
    }

    @Override
    public JsonResult exhibitRanking(String type, String startTime, String endTime, String code) {
        HashMap hm = new HashMap();
        hm.put("title","上货物料排名");
        List<HashMap> list = new ArrayList<>();
        if(StringUtils.isNotBlank(type)){
            if(type.equals("1")){
                list.addAll(weighCabinetReportDao.exhibitRanking(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(type.equals("2")){
                list.addAll(weighCabinetReportDao.exhibitRanking(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(type.equals("3")){
                list.addAll(weighCabinetReportDao.exhibitRanking(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.exhibitRanking(start,end,code));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findReplenishmentMaterial(String type, String startTime, String endTime, String code) {
        HashMap hm = new HashMap();
        hm.put("title","补货物料排名");
        List<HashMap> list = new ArrayList<>();
        if(StringUtils.isNotBlank(type)){
            if(type.equals("1")){
                list.addAll(weighCabinetReportDao.replenishmentMaterial(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(type.equals("2")){
                list.addAll(weighCabinetReportDao.replenishmentMaterial(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(type.equals("3")){
                list.addAll(weighCabinetReportDao.replenishmentMaterial(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.replenishmentMaterial(start,end,code));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findMaterialConsumption(String type, String startTime, String endTime, String other, String param, String code) {
        HashMap hm = new HashMap();
        hm.put("title","物料消耗量(产品)");
        List<HashMap> list = new ArrayList<>();
        if (type.equals("1")){
            if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByOldSpecCode(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),param,code));
            }else if(other.equals("category")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByCategory(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),param,code));
            }
        }else if(type.equals("2")){
            if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByOldSpecCode(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),param,code));
            }else if(other.equals("category")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByCategory(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),param,code));
            }
        }else if(type.equals("3")){
            if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByOldSpecCode(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),param,code));
            }else if(other.equals("category")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByCategory(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),param,code));
            }
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByOldSpecCode(start,end,param,code));
            }else if(other.equals("category")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByCategory(start,end,param,code));
            }
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findMaterialByType(String type, String startTime, String endTime, String param, String code) {
        HashMap hm = new HashMap();
        hm.put("title","物料类型");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByType(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),param,code));
        }else if(type.equals("2")){
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByType(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),param,code));
        }else if(type.equals("3")){
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByType(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),param,code));
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByType(start,end,param,code));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findRequisitionStatistics(String type, String startTime, String endTime, String other, String param, String code) {
        HashMap hm = new HashMap();
        hm.put("title","员工领用统计");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            if(other.equals("user")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByUser(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),param,code));
            }else if(other.equals("dept")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByDept(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),param,code));
            }
        }else if(type.equals("2")){
            if(other.equals("user")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByUser(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),param,code));
            }else if(other.equals("dept")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByDept(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),param,code));
            }
        }else if(type.equals("3")){
            if(other.equals("user")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByUser(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),param,code));
            }else if(other.equals("dept")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByDept(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),param,code));
            }
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            if(other.equals("user")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByUser(start,end,param,code));
            }else if(other.equals("dept")){
                list.addAll(weighCabinetReportDao.queryMaterialConsumptionByDept(start,end,param,code));
            }
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findMaterialConsumeByBrand(String type, String startTime, String endTime, String param, String code) {
        HashMap hm = new HashMap();
        hm.put("title","物料消耗品牌");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByBrand(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),param,code));
        }else if(type.equals("2")){
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByBrand(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),param,code));
        }else if(type.equals("3")){
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByBrand(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),param,code));
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.queryMaterialConsumptionByBrand(start,end,param,code));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findProportionOfReturnedMaterials(String type, String startTime, String endTime, String other, String code) {
        HashMap hm = new HashMap();
        hm.put("title","退料物料占比");
        List<HashMap> list = new ArrayList<>();
        if (type.equals("1")){
            if(other.equals("skuCode")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialBySkuCode(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }else if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialByOldSpecCode(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code));
            }
        }else if(type.equals("2")){
            if(other.equals("skuCode")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialBySkuCode(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }else if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialByOldSpecCode(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code));
            }
        }else if(type.equals("3")){
            if(other.equals("skuCode")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialBySkuCode(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }else if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialByOldSpecCode(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code));
            }
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            if(other.equals("skuCode")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialBySkuCode(start,end,code));
            }else if(other.equals("oldSpec")){
                list.addAll(weighCabinetReportDao.queryReturnedMaterialByOldSpecCode(start,end,code));
            }
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findReturnedMaterialRanking(String type, String startTime, String endTime, String code) {
        String databaseUser = DynamicDataSource.USER_PREFIX;
        if (StringUtils.isNotBlank(DynamicDataSource.name.get())) {
            databaseUser = databaseUser + "-" + DynamicDataSource.name.get();
        }

        HashMap hm = new HashMap();
        hm.put("title","退料物料排名");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            list.addAll(weighCabinetReportDao.queryReturnedMaterialByUserId(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,databaseUser));
        }else if(type.equals("2")){
            list.addAll(weighCabinetReportDao.queryReturnedMaterialByUserId(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,databaseUser));
        }else if(type.equals("3")){
            list.addAll(weighCabinetReportDao.queryReturnedMaterialByUserId(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,databaseUser));
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.queryReturnedMaterialByUserId(start,end,code,databaseUser));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findRepairMaterialBySkuCode(String type, String startTime, String endTime, String code,Integer businessType) {
        HashMap hm = new HashMap();
        hm.put("title","物料消耗排名（按物料）");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialBySkuCode(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,businessType));
        }else if(type.equals("2")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialBySkuCode(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,businessType));
        }else if(type.equals("3")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialBySkuCode(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,businessType));
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.queryRepairMaterialBySkuCode(start,end,code,businessType));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findRepairMaterialByUser(String type, String startTime, String endTime, String code,Integer businessType) {
        String databaseUser = DynamicDataSource.USER_PREFIX;
        if (StringUtils.isNotBlank(DynamicDataSource.name.get())) {
            databaseUser = databaseUser + "-" + DynamicDataSource.name.get();
        }

        HashMap hm = new HashMap();
        hm.put("title","物料消耗排名（按人员）");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialByUser(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,businessType,databaseUser));
        }else if(type.equals("2")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialByUser(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,businessType,databaseUser));
        }else if(type.equals("3")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialByUser(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,businessType,databaseUser));
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.queryRepairMaterialByUser(start,end,code,businessType,databaseUser));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }

    @Override
    public JsonResult findRepairMaterialByProductType(String type, String startTime, String endTime, String code,Integer businessType) {
        HashMap hm = new HashMap();
        hm.put("title","物料消耗排名（按类型）");
        List<HashMap> list = new ArrayList<>();
        if(type.equals("1")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialByProductType(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,businessType));
            hm.put("sum",weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.dayUtil().get(0),FindDateStatusUtil.dayUtil().get(1),code,businessType));
        }else if(type.equals("2")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialByProductType(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,businessType));
            hm.put("sum",weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.weekUtil().get(0),FindDateStatusUtil.weekUtil().get(1),code,businessType));
        }else if(type.equals("3")){
            list.addAll(weighCabinetReportDao.queryRepairMaterialByProductType(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,businessType));
            hm.put("sum",weighCabinetReportDao.queryOrderedInspectionQuantity(FindDateStatusUtil.dateUtil().get(0),FindDateStatusUtil.dateUtil().get(1),code,businessType));
        }
        if(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            LocalDateTime start = LocalDateTimeUtils.convertStringToLDT(startTime,"yyyy-MM-dd HH:mm:ss");
            LocalDateTime end = LocalDateTimeUtils.convertStringToLDT(endTime,"yyyy-MM-dd HH:mm:ss");
            list.addAll(weighCabinetReportDao.queryRepairMaterialByProductType(start,end,code,businessType));
            hm.put("sum",weighCabinetReportDao.queryOrderedInspectionQuantity(start,end,code,businessType));
        }
        hm.put("list",list);
        return JsonResult.success("查询成功",hm);
    }


}
